# Contributor: Henrik Riomar <henrik.riomar@gmail.com>
# Maintainer: Drew DeVault <sir@cmpwn.com>
pkgname=swayidle
pkgver=1.6
pkgrel=2
pkgdesc="Idle management daemon for Wayland"
url="https://swaywm.org"
arch="all"
license="MIT"
options="!check" # no test suite
makedepends="
	elogind-dev
	meson
	ninja
	scdoc
	wayland-dev
	wayland-protocols
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion:bashcomp:noarch
	$pkgname-fish-completion:fishcomp:noarch
	$pkgname-zsh-completion:zshcomp:noarch
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/swaywm/swayidle/archive/$pkgver.tar.gz"

build() {
	meson build \
		--prefix=/usr \
		--buildtype=plain \
		-Dlogind=enabled \
		-Dlogind-provider=elogind
	ninja -C build
}

package() {
	DESTDIR="$pkgdir" ninja -C build install
}

bashcomp() {
	depends=""
	pkgdesc="Bash completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	mkdir -p "$subpkgdir"/usr/share/
	mv "$pkgdir"/usr/share/bash-completion "$subpkgdir"/usr/share/
}

fishcomp() {
	depends=""
	pkgdesc="Fish completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel fish"

	mkdir -p "$subpkgdir"/usr/share/fish
	mv "$pkgdir"/usr/share/fish/vendor_completions.d "$subpkgdir"/usr/share/fish/completions
}

zshcomp() {
	depends=""
	pkgdesc="Zsh completions for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	mkdir -p "$subpkgdir"/usr/share/zsh
	mv "$pkgdir"/usr/share/zsh/site-functions "$subpkgdir"/usr/share/zsh
}

sha512sums="c82b0d2aee06f87fd71e9e2208e917c0dc7afe80ab0b782c3165127519445021d8cf363292eee99f939165eb813909f2a4ee74153e776557c6d06672de2c1c82  swayidle-1.6.tar.gz"
